package com.xunqi.activemq.produce;

import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * @Description:
 * @Created: with IntelliJ IDEA.
 * @author: 夏沫止水
 * @createTime: 2020-06-23 10:47
 **/

@Component
public class TopicProduce {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private ActiveMQTopic activeMQTopic;


    @Scheduled(fixedDelay = 3000L)
    public void produceTopic() {
        jmsMessagingTemplate.convertAndSend(activeMQTopic,"主题消息：" + UUID.randomUUID().toString().substring(0,6));
        System.out.println("********Scheduled Topic 已投递");

    }

}
